#!/bin/bash
#
vip='10.2.20.251'
netmask='255.255.255.255'
iface='lo:0'

start(){
	echo "1" > /proc/sys/net/ipv4/conf/all/arp_ignore
	echo "1" > /proc/sys/net/ipv4/conf/lo/arp_ignore
	echo "2" > /proc/sys/net/ipv4/conf/all/arp_announce
	echo "2" > /proc/sys/net/ipv4/conf/lo/arp_announce
	/usr/sbin/ifconfig $iface $vip netmask $netmask broadcast $vip  up
	/usr/sbin/route add -host $vip dev $iface
}

stop(){
	/usr/sbin/ifconfig $iface down
	echo "0" > /proc/sys/net/ipv4/conf/all/arp_ignore
	echo "0" > /proc/sys/net/ipv4/conf/lo/arp_ignore
	echo "0" > /proc/sys/net/ipv4/conf/all/arp_announce
	echo "0" > /proc/sys/net/ipv4/conf/lo/arp_announce
}

case $1 in
start)
	start
	;;
stop)
	stop
	;;
*)
	echo "Usage: $0 [start|stop]"
	exit 1
esac
